﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Model;

namespace Dao
{
    /// <summary>
    /// Dao层基类
    /// </summary>
    /// <typeparam name="M">主键的类型</typeparam>
    /// <typeparam name="T">Model类型</typeparam>
    public interface BaseDao<M, T>
    {
        /// <summary>
        /// 保存
        /// </summary>
        /// <param name="t"></param>
        int Save(T t);
        /// <summary>
        /// 修改
        /// </summary>
        /// <param name="t"></param>
        int Update(T t);
        /// <summary>
        /// 删除
        /// </summary>
        /// <param name="m">唯一标识</param>
        /// <returns></returns>
        int Delete(M m);
        /// <summary>
        /// 查询
        /// </summary>
        /// <param name="t"></param>
        /// <returns></returns>
        List<T> Search(T t);

        /// <summary>
        /// 通过主键查询
        /// </summary>
        /// <param name="m">主键</param>
        /// <returns></returns>
        T SearchByPrimaryKey(M m);
        /// <summary>
        /// 查询一个结果（如果有多个结果，取第一个）
        /// </summary>
        /// <param name="t"></param>
        /// <returns></returns>
        T SearchOne(T t);
    }
}
